package com.tanhua.server.service;

import com.alibaba.dubbo.config.annotation.Reference;
import com.tanhua.common.pojo.User;
import com.tanhua.common.utils.UserThreadLocal;
import com.tanhua.dubbo.server.api.UserLikeApi;
import com.tanhua.server.vo.CountsVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class UserCountService {
    @Reference(version = "1.0.0")
    private UserLikeApi userLikeApi;


    /**
     * 获取互相喜欢,喜欢,粉丝的数量
     *
     * @return
     */
    public CountsVo getCountUsers() {
        try {
            User user = UserThreadLocal.get();
            Long userId = user.getId();
            CountsVo countsVo = new CountsVo();
            countsVo.setEachLoveCount(userLikeApi.queryMutualLikeCount(userId));
            countsVo.setFanCount(userLikeApi.queryFanCount(userId));
            countsVo.setLoveCount(userLikeApi.queryLikeCount(userId));
            return countsVo;
        } catch (Exception e) {
            return null;
        }
    }
}
